// pages/home/home.js
//获取应用实例
const app = getApp()
Page({
  data: {
    userInfo: null,
    lists: [{
      id: '1',
      name: "路飞",
      image: "../../image/luffy.jpg"
    },
    {
      id: '2',
      name: "理想三旬",
      image: "../../image/avatar.jpg"
    },
    {
      id: '3',
      name: "索隆",
      image: "../../image/zerro.jpg"
    },
    {
      id: '4',
      name: "sunny",
      image: "../../image/sunny.jpg"
    },
    {
      id: '5',
      name: "鸭仔",
      image: "../../image/duck.jpg"
    }
    ]
  },
  onLoad: function () {
    let that = this;
    //判断是否已授权
    wx.getSetting({
      success(res) {
        if (res.authSetting['scope.userInfo']) {
          wx.getUserInfo({
            lang: 'zh_CN',
            success(res) {
              app.globalData.userInfo = res.userInfo;
              that.setData({
                userInfo: res.userInfo
              })
              //从数据库获取用户信息
              //that.queryUserInfo();
            }
          })
        } else {
          //用户没有授权过
          wx.redirectTo({
            url: '../login/login'
          })
        }
      }
    })
  },
  onShow: function () {

  },
  onShareAppMessage: function () {
    return {
      title: '理想三旬',
      desc: 'my_first',
      path: 'pages/home/home'
    }
  },
  show(){
    console.log("============show")
    wx.requestPayment({
      timeStamp: '',
      nonceStr: '',
      package: '',
      signType: 'MD5',
      paySign: '',
      success(res) { },
      fail(res) { }
    })
  }
})